package mywebapps.common.utils;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;



public class HibernateUtil
{
    private static HibernateUtil instance = null;
    private SessionFactory sessionFactory = null;
    
    private HibernateUtil() 
    {
        sessionFactory = new Configuration().configure().buildSessionFactory();
//    	sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
    }
    
    public static HibernateUtil getInstance() 
    {
        if (instance == null) 
        {
            synchronized(HibernateUtil.class) 
            {
                if (instance == null) 
                {
                    instance = new HibernateUtil();
                }
            }
        }
        
        return instance;
    }
    
    public SessionFactory getSessionFactory()
    {
        return sessionFactory;
    }
}
